package com.huawei.appmarket.service.webview.delegate;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.huawei.appgallery.agwebview.api.delegate.GeneralWebViewDelegate;
import com.huawei.appgallery.agwebview.api.ui.IWebViewActivityProtocol;
import com.huawei.appmarket.service.webview.js.HwHiAppPrivacyJs;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import o.cvx;
import o.der.f;
import o.Logger;
import o.dof;
import o.eee;
import o.epw;

public class ProtocolWebviewDelegate extends GeneralWebViewDelegate {
    private boolean ˈ;

    static class e implements OnLongClickListener {
        private e() {
        }

        public boolean onLongClick(View view) {
            Logger.ˎ("ProtocolWebviewDelegate", "OOBE OnLongClick invalid");
            return true;
        }
    }

    public ProtocolWebviewDelegate() {
        this.ˈ = false;
        this.ˏॱ = true;
        this.ˊॱ = false;
    }

    public void ॱˋ() {
        super.ॱˋ();
        if (eee.ˊ() && this.ˈ && eee.ॱ(this.ʼ.getContext()) && (this.ˊ instanceof Activity)) {
            ˌ();
        }
    }

    private void ˌ() {
        Window window = ((Activity) this.ˊ).getWindow();
        if (window != null) {
            View decorView = window.getDecorView();
            if (decorView != null) {
                int i = 4098;
                if (!epw.ˏ()) {
                    i = 12306;
                }
                decorView.setSystemUiVisibility(i);
                window.setStatusBarColor(0);
            }
        }
    }

    public void ॱ(Activity activity) {
    }

    public void ˎ(View view) {
        super.ˎ(view);
        this.ˏ.setBackgroundColor(this.ˊ.getResources().getColor(a.ˊ));
    }

    public void ʽ(String str) {
        HwHiAppPrivacyJs hwHiAppPrivacyJs = new HwHiAppPrivacyJs(this.ˊ);
        this.ʼ.addJavascriptInterface(hwHiAppPrivacyJs, HwHiAppPrivacyJs.JS_AGRATTR_NAME);
        if (eee.ˊ() && this.ˈ) {
            this.ʼ.addJavascriptInterface(hwHiAppPrivacyJs, HwHiAppPrivacyJs.JS_CHECK_MORE_NAME);
            if (eee.ॱ(this.ʼ.getContext())) {
                this.ʼ.setOnLongClickListener(new e());
            }
        }
        this.ʼ.loadUrl(str);
    }

    public boolean ˊ(Context context, IWebViewActivityProtocol iWebViewActivityProtocol) {
        String url = iWebViewActivityProtocol.getUrl();
        if (dof.ˋ(url)) {
            return false;
        }
        this.ˈ = url.startsWith("file:///android_asset/privacy/privacy");
        if (super.ˊ(context, iWebViewActivityProtocol) && ͺ(url)) {
            return true;
        }
        return false;
    }

    protected boolean ͺ(String str) {
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        if (str.startsWith(cvx.ˎ("user.protocol.domian")) || str.startsWith(cvx.ˎ("app.privacy.domain")) || str.startsWith(cvx.ˎ("consumer.privacy.domain")) || str.startsWith("file:///android_asset/about/OpenSourceSoftwareNotice.html") || str.startsWith("file:///android_asset/privacy/privacy")) {
            return true;
        }
        return false;
    }

    public WebViewClient ˊˋ() {
        return new com.huawei.appgallery.agwebview.api.delegate.GeneralWebViewDelegate.e(this) {
            final /* synthetic */ ProtocolWebviewDelegate ˎ;

            {
                this.ˎ = r1;
            }

            public boolean shouldOverrideUrlLoading(WebView webView, String str) {
                if (dof.ॱ(str)) {
                    Logger.ˋ("ProtocolWebviewDelegate", "url is empty");
                } else {
                    try {
                        Intent intent = new Intent(ACTION.HWID_SCHEME_URL, Uri.parse(str));
                        if (!this.ˎ.ͺ()) {
                            intent.setFlags(268435456);
                        }
                        this.ˎ.ˏॱ().startActivity(intent);
                    } catch (Exception e) {
                        Logger.ˋ("ProtocolWebviewDelegate", "There is no browser");
                    }
                }
                return true;
            }
        };
    }

    public void ʻ(String str) {
    }

    public void ˊॱ() {
        this.ʼ.reload();
        this.ʼ.setVisibility(0);
        this.ᐝ.setVisibility(8);
    }

    public void ˊ(String str) {
        if (!TextUtils.isEmpty(this.ॱᐝ) && this.ॱᐝ.startsWith("file:///android_asset/about/OpenSourceSoftwareNotice.html")) {
            str = ˏॱ().getString(f.ʻʻ);
        }
        super.ˊ(str);
    }

    public String ʾ() {
        return "ProtocolWebviewDelegate";
    }
}
